$(function(){
	var index = -1;
	//点击添加
	$("#add").click(function(){
		$(".background_bord").show();
		$(".add_span").show();
		$(".update_span").hide();
		$("#expatriateId").val("");
		$("#expatriateName5").val("");
		$("#expatriateEducation").val("");
		$("#expatriateArea").val("");
		$("#expatriateExperience").val("");
		$("#expatriateSkill").val("");
		$("#expatriateSalary").val("");
		$("#expatriateStatus").val("");
		$("#form_adup").prop("action","../expatriate/insert.action");
	});
	//退出弹出框
	$("#img_exit").click(function(){
		$(".background_bord").hide();
	});
	//点击修改按钮
	$("#update").click(function(){
		if(index == -1){
			ShowMessage("请选择您要修改的数据");
			return true;
		}else{
			$(".background_bord").show();
			$(".add_span").hide();
			$(".update_span").show();
			var expatriateId = $(".table_tr_date").eq(index).find(".expatriateId").val();
			var expatriateName = $(".table_tr_date").eq(index).find(".expatriateName").text();
			var expatriateEducation = $(".table_tr_date").eq(index).find(".expatriateEducation").text();
			var expatriateArea = $(".table_tr_date").eq(index).find(".expatriateArea").text();
			var expatriateExperience = $(".table_tr_date").eq(index).find(".expatriateExperience").text();
			var expatriateSkill = $(".table_tr_date").eq(index).find(".expatriateSkill").text();
			var expatriateSalary = $(".table_tr_date").eq(index).find(".expatriateSalary").text();
			var expatriateStatus = $(".table_tr_date").eq(index).find(".expatriateStatus").text();
			$("#expatriateId").val(expatriateId);
			$("#expatriateName5").val(expatriateName);
			$("#expatriateEducation").val(expatriateEducation);
			$("#expatriateArea").val(expatriateArea);
			$("#expatriateExperience").val(expatriateExperience);
			$("#expatriateSkill").val(expatriateSkill);
			$("#expatriateSalary").val(expatriateSalary);
			$("#expatriateStatus").val(expatriateStatus);
			$("#form_adup").prop("action","../expatriate/update.action");
			return false;
		}
	});
	//点击table行
	$(".table_tr_date").click(function(){
		if($(this).find("td").css("font-weight")=="bold"){
			$(".table_tr_date").find("td").removeClass("select_tr")
			$(this).find("input[type='radio']").prop("checked",false);
			index = -1;
		}else{
			$(".table_tr_date").find("td").removeClass("select_tr")
			$(this).find("td").addClass("select_tr");
			$(".result_list_table").find("input[type='radio']").prop("checked",false);
			$(this).find("input[type='radio']").prop("checked",true);
			index = $(this).index()-1;
		}
	});
});